using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SunFlower : Plant
{

    private float ProductionCycle = 15f;
    private float ProductionTimer;
    private Vector3 position;


    void Start()
    {
        
    }

    void Update()
    {
        if (curState != PlantState.Planted) return;
        if (ProductionTimer >= ProductionCycle)
        {
            ProductionTimer = 0;
        }
        ProductionTimer += Time.deltaTime;
        if (ProductionTimer >= ProductionCycle)
        {
            ProduceSun();
        }

    }

    void ProduceSun()
    {

        position = transform.position;

        GameObject sunPrefab = ResourceManager.Instance.Sun;

        Vector3 newPosition =  new Vector3(Random.Range(position.x - 1, position.x + 1), Random.Range(position.y - 1, position.y + 1),0);

        Instantiate(sunPrefab,newPosition,transform.rotation);

    }






}
